let head = [3, 2, 0, -4]
function ListNode(val) {
    this.val = val;
    this.next = null;
}
let list = new ListNode(head[0])
let num = list
for (let i = 1; i < head.length; i++) {
    num.next = new ListNode(head[i])
    num = num.next
};
// var detectCycle = function (head) {
//     let slow = head
//     let fast = head
//     let num = head
//     while (fast && fast.next) {
//         slow = slow.next
//         fast = fast.next.next
//         if (fast === slow) {
//             while (num !== slow) {
//                 num = num.next
//                 slow = slow.next
//             }
//             return slow
//         }

//     }
//     return null
// };
// console.log(detectCycle(k = list));

